'''
Author: @zhyy
Date: 2021-02-01 14:17:03
LastEditors: @zhyy
LastEditTime: 2021-02-01 16:29:48
'''
import datetime
from app.validators.jwt_auth import generate_jwt
from flask import current_app, g


def generate_token(self, user_id, scope):
    """
    生成token 和refresh_token
    :param user_id: 用户id
    :return: token2小时, refresh_token14天
    """
    # 生成token
    token = generate_jwt(
        {'user_id': user_id, 'refresh': False, 'scope': scope}, expiry=current_app.config['TOKEN_EXPIRATION'])
    return token


